package cn.mifengkong.appcommon.util;

import android.app.ActivityManager;
import android.content.Context;

import java.util.List;


/**
 * Created by jiangyongxing on 2017/7/6.
 * 描述：
 */

public class ProcessUtil {

    public static String getProcessName(Context cxt, int pid) {
        ActivityManager am = (ActivityManager) cxt.getSystemService(Context.ACTIVITY_SERVICE);
        List<ActivityManager.RunningAppProcessInfo> runningApps = am.getRunningAppProcesses();
        if (runningApps == null) {
            return null;
        }
        for (ActivityManager.RunningAppProcessInfo procInfo : runningApps) {
            if (procInfo.pid == pid) {
                return procInfo.processName;
            }
        }
        return null;
    }

    public static boolean defaultProcess(String application_id,String processName) {
        return processName.equalsIgnoreCase(application_id);
    }

    public static boolean baiduLocationProcess(String processName) {
        return processName.contains(":remote");
    }

    public static boolean talkingDataProcess(String processName) {
        return processName.contains(".TDAntiCheatingService");
    }

    public static boolean getuiProcess(String processName) {
        return processName.contains(":pushservice");
    }
}
